package com.example.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;

import com.example.myapplication.ui.PullToRefreshActivity;


public class StartActivity extends Activity {

    private CountDownTimer timer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        start_timer();
    }

    private void start_timer() {
        timer = new CountDownTimer(1000, 1000) {

            @Override
            public void onTick(long millisUntilFinished) {
            }

            @Override
            public void onFinish() {
                Intent intent = new Intent();
                intent.setClass(getApplicationContext(), PullToRefreshActivity.class);
                startActivity(intent);
                overridePendingTransition(
                        R.anim.anim_out, R.anim.anim_in);
                finish();
            }
        }.start();
    }

    private void timer_cancle() {
        if (timer != null) {
            timer.cancel();
            timer = null;
        }
    }

    @Override
    protected void onDestroy() {
        timer_cancle();
        super.onDestroy();
    }
}